<?php echo $this->render('link/header.phtml') ?>
//常用变量初始化
var menuCheckUrl=baseUrl+"/link/serverlink/type/check";
var module="linkcheck";
var gridTitle="链接信息审核";
var dataId="link_id";
var link = Ext.data.Record.create([
           {name: 'link_id', type: 'int'},
           {name: 'link_site_id', type: 'string'},
		   {name: 'link_linktype_id', type: 'string'},
           {name:'link_client_id',type:'string'},
           {name: 'link_address', type: 'string'},
           {name: 'link_client_id', type: 'string'},
           {name:'link_ischeck',type:'string'}
      ]);

client_combo_store.load();
var client_combo=new Ext.form.ComboBox({
										width:280,
										 fieldLabel:'选择客户',
										 store:client_combo_store,										
        								displayField:'client_host',
        								valueField :'client_id',
										hiddenName:"client_id",
        								typeAhead:true,
        								triggerAction:'all',
                                        queryParam:'client_host',                                                                               
                                        //hideTrigger: true, //隐藏下拉箭头   
										loadingText: '正在加载...',
                                        pageSize:8,
                                        minChars:1,
                                        queryDelay:300,   
                                        mode :'remote',  
        								emptyText:'请选择...',                                       
        								selectOnFocus:true,
                                        resizable:true, 
                                        listeners:{
                                        	select:function(){
                                            ds.baseParams.where="link_client_id='"+this.value+"'";
                                            ds.reload();
                                        	//ds.load({params:{start:0,limit:30,where:"link_client_id='"+this.value+"'"}});	
                                        	}
                                        }
										 });   
var ds=new Ext.data.Store({
							  proxy:new Ext.data.HttpProxy({
									url:baseUrl+'/link/serverlink/type/getAll'
									}),
							  reader:new Ext.data.JsonReader({
									root:'results',
									totalProperty:'total',
									id:'link_id'
									},link)
	});		 
//定义列模型
var cm=new Ext.grid.ColumnModel([	
							new Ext.grid.CheckboxSelectionModel(),
                            {header:'链接ID',dataIndex:'link_id',width:50,hidden:true},														
							{header:'客户ID',dataIndex:'link_client_id',width:150,hidden:true},
							{header:'链接类型ID',dataIndex:'link_linktype_id',width:150,hidden:true},						
                            {header:'链接地址',dataIndex:'link_address',width:200},											
                            {header:'审核状态',dataIndex:'link_ischeck',width:70,renderer:show_check_status}						
	]);
cm.defaultSortable = true; 



//定义工具栏								 
var tb=new Ext.Toolbar({
							items:[

                                         {
                                            id:'menuCheck'+ExtId,
											text:'审核通过',
											iconCls:'icn-ok',
											handler:menuCheckOk
											},
                                              {
                                            id:'menuCheck'+ExtId,
											text:'审核失败',
											iconCls:'icn-cross',
											handler:menuCheckError
											},
                                            "-","客户:",client_combo										 
								 ]
	});			
   
function menuCheckOk(){
menuCheck(true);
}
function menuCheckError(){
menuCheck(false);
}

function menuCheck(flag){
	var selectRows=grid.getSelectionModel().getSelections();												
												if(selectRows.length==0){
													Ext.MessageBox.alert('提示','请选择一条数据');
													}
												else{		
													var message="";
													for(var i=0;i<selectRows.length;i++){
														if(i!=0){
															message+=",";
															}
														message+=selectRows[i].get(dataId);
														}
													Ext.Ajax.request({
																	 url:menuCheckUrl,
																	 params:{id:message,flag:flag},																																		 																	success:function(response,option){
																var temp=Ext.util.JSON.decode(response.responseText);																
																ds.load({params:{start:0,limit:30}});
																grid.render();
																		 },
																	failure:function(response,option){
																		var temp=Ext.util.JSON.decode(response.responseText);
																		Ext.MessageBox.alert('waring',temp.msg);
																		}
																	 });
													}
}

<?php echo $this->render('link/foot.phtml') ?>
